The setTimeout call returns an id. Use this id to cancel the timeout with clearTimeout(). For example, press this "Press and Wait" button to create a three-second delay. Wait a few seconds and you will see that it works just like the example above. Now tap it again but hit the cancel button before three seconds have passed and stop the message from appearing. Wait a few seconds and you will see that nothing more happens. The timeout has been cancelled.
JSCTimeOut = window.setTimeout("PopIt('Timeout','Three seconds have passed')",1000)
and...
onClick="clearTimeout(JSCTimeOut)"
setTimeout(anExpression, milliSecs) | Evaluate expressions after a delay, e.g., myID = setTimeout("myFunct()",5000) Used to create pending actions. |
clearTimeout(anID) | Clears a timeout set by setTimeout(), e.g., clearTimeout(myID). Used to cancel a pending action. |